

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/fluid.png">
  <link rel="icon" href="/img/fluid.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="John Doe">
  <meta name="keywords" content="">
  
    <meta name="description" content="@[toc] 一、Spring 概述 参考资料：https:&#x2F;&#x2F;baike.baidu.com&#x2F;item&#x2F;spring&#x2F;85061?fr&#x3D;aladdinSpring 是 JavaEE 编程领域的一个轻量级开源框架，由Rod Johnson 先生在2002年最早提出并随后创建。 Spring 是一个开源容器框架，集成各类型的工具，通过核心的 Bean Factory 实现了底层的类的实例化和生命周期">
<meta property="og:type" content="article">
<meta property="og:title" content="设计模式 笔记7 _ 抽象工厂模式 在源码中的应用 Spring篇">
<meta property="og:url" content="http://example.com/2022/07/25/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F%20%E7%AC%94%E8%AE%B07%20_%20%E6%8A%BD%E8%B1%A1%E5%B7%A5%E5%8E%82%E6%A8%A1%E5%BC%8F%20%E5%9C%A8%E6%BA%90%E7%A0%81%E4%B8%AD%E7%9A%84%E5%BA%94%E7%94%A8%20Spring%E7%AF%87/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="@[toc] 一、Spring 概述 参考资料：https:&#x2F;&#x2F;baike.baidu.com&#x2F;item&#x2F;spring&#x2F;85061?fr&#x3D;aladdinSpring 是 JavaEE 编程领域的一个轻量级开源框架，由Rod Johnson 先生在2002年最早提出并随后创建。 Spring 是一个开源容器框架，集成各类型的工具，通过核心的 Bean Factory 实现了底层的类的实例化和生命周期">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2022-07-25T02:49:50.000Z">
<meta property="article:modified_time" content="2022-08-22T15:41:12.215Z">
<meta property="article:author" content="John Doe">
<meta property="article:tag" content="设计模式">
<meta name="twitter:card" content="summary_large_image">
  
  
  
  <title>设计模式 笔记7 _ 抽象工厂模式 在源码中的应用 Spring篇 - Hexo</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"example.com","root":"/","version":"1.9.2","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml"};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 6.2.0"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>尤 Ni&#39;s Blog</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/img/default.png') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="设计模式 笔记7 _ 抽象工厂模式 在源码中的应用 Spring篇"></span>
          
        </div>

        
          
  <div class="mt-3">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-author" aria-hidden="true"></i>
        John Doe
      </span>
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2022-07-25 10:49" pubdate>
          2022年7月25日 上午
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          4.2k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          35 分钟
        
      </span>
    

    
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">设计模式 笔记7 _ 抽象工厂模式 在源码中的应用 Spring篇</h1>
            
              <p class="note note-info">
                
                  
                    本文最后更新于：1 小时前
                  
                
              </p>
            
            
              <div class="markdown-body">
                
                <p>@[toc]</p>
<h1 id="一、Spring-概述"><a href="#一、Spring-概述" class="headerlink" title="一、Spring 概述"></a>一、Spring 概述</h1><hr>
<p>参考资料：<a target="_blank" rel="noopener" href="https://baike.baidu.com/item/spring/85061?fr=aladdin">https://baike.baidu.com/item/spring/85061?fr=aladdin</a><br>Spring 是 JavaEE 编程领域的一个轻量级开源框架，由Rod Johnson 先生在2002年最早提出并随后创建。</p>
<p>Spring 是一个开源容器框架，集成各类型的工具，通过核心的 Bean Factory 实现了底层的类的实例化和生命周期的管理。</p>
<p>Spring 的主要特点：</p>
<ul>
<li><strong>IoC（Inverse of Control 控制反转）</strong>，实现低耦合，底层采用工厂设计模式，所有的 Bean 都需注册到 Bean 工厂中，将 Bean 的初始化和生命周期的监控都交给工厂进行管理</li>
<li><strong>AOP （Aspect Oriented Programming）</strong> 面向切面编程</li>
<li><strong>DI （Dependency Injection）</strong> 依赖注入，可以注入普通类型或者对象到 Spring 容器中</li>
</ul>
<h1 id="二、Spring-中的抽象工厂模式"><a href="#二、Spring-中的抽象工厂模式" class="headerlink" title="二、Spring 中的抽象工厂模式"></a>二、Spring 中的抽象工厂模式</h1><hr>
<p>运行环境：</p>
<ul>
<li>SpringBoot v2.6.9 </li>
<li>Spring v5.3.21</li>
</ul>
<p>由于 Spring 的几大特点： IoC 、DI 和 AOP 得知，其底层使用 Bean 工厂来注册与管理 Bean，即 Java 的普通类型和对象，那么我们可以来了解一下其底层的 Bean 工厂：</p>
<p><code>org.springframework.beans.factory.BeanFactory</code></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-keyword">package</span> org.springframework.beans.factory;<br><br><span class="hljs-keyword">import</span> org.springframework.beans.BeansException;<br><span class="hljs-keyword">import</span> org.springframework.core.ResolvableType;<br><span class="hljs-keyword">import</span> org.springframework.lang.Nullable;<br><br><span class="hljs-keyword">public</span> <span class="hljs-keyword">interface</span> <span class="hljs-title class_">BeanFactory</span> &#123;<br><br>    <span class="hljs-comment">// Bean 自带的前缀</span><br>	<span class="hljs-type">String</span> <span class="hljs-variable">FACTORY_BEAN_PREFIX</span> <span class="hljs-operator">=</span> <span class="hljs-string">&quot;&amp;&quot;</span>;<br>    <span class="hljs-comment">// 1. 根据名称获取 Bean</span><br>	Object <span class="hljs-title function_">getBean</span><span class="hljs-params">(String name)</span> <span class="hljs-keyword">throws</span> BeansException;<br>    <span class="hljs-comment">// 2. 根据名称获取 Bean, 并转化为指定的对象</span><br>	&lt;T&gt; T <span class="hljs-title function_">getBean</span><span class="hljs-params">(String name, Class&lt;T&gt; requiredType)</span> <span class="hljs-keyword">throws</span> BeansException;<br>    <span class="hljs-comment">// 3. 根据名称获取 Bean, 并传入构造该Bean的参数，用于有参构造</span><br>	Object <span class="hljs-title function_">getBean</span><span class="hljs-params">(String name, Object... args)</span> <span class="hljs-keyword">throws</span> BeansException;<br>    <span class="hljs-comment">// 4. 根据字节码获取 Bean</span><br>	&lt;T&gt; T <span class="hljs-title function_">getBean</span><span class="hljs-params">(Class&lt;T&gt; requiredType)</span> <span class="hljs-keyword">throws</span> BeansException;<br>    <span class="hljs-comment">// 5. 根据字节码获取 Bean，并传入构造该Bean的参数，用于有参构造</span><br>	&lt;T&gt; T <span class="hljs-title function_">getBean</span><span class="hljs-params">(Class&lt;T&gt; requiredType, Object... args)</span> <span class="hljs-keyword">throws</span> BeansException;<br>    <span class="hljs-comment">// 6. 根据字节码获取指定 Bean 的提供者</span><br>	&lt;T&gt; ObjectProvider&lt;T&gt; <span class="hljs-title function_">getBeanProvider</span><span class="hljs-params">(Class&lt;T&gt; requiredType)</span>;<br>    <span class="hljs-comment">// 7. 根据指定的解析类型获取 Bean 的提供者</span><br>	&lt;T&gt; ObjectProvider&lt;T&gt; <span class="hljs-title function_">getBeanProvider</span><span class="hljs-params">(ResolvableType requiredType)</span>;<br>    <span class="hljs-comment">// 8. 判断工厂是否包含 Bean</span><br>	<span class="hljs-type">boolean</span> <span class="hljs-title function_">containsBean</span><span class="hljs-params">(String name)</span>;<br>    <span class="hljs-comment">// 9. 根据名称判断 Bean 是否为单例的对象</span><br>	<span class="hljs-type">boolean</span> <span class="hljs-title function_">isSingleton</span><span class="hljs-params">(String name)</span> <span class="hljs-keyword">throws</span> NoSuchBeanDefinitionException;<br>    <span class="hljs-comment">// 10. 根据名称判断 Bean 是否为原型对象</span><br>	<span class="hljs-type">boolean</span> <span class="hljs-title function_">isPrototype</span><span class="hljs-params">(String name)</span> <span class="hljs-keyword">throws</span> NoSuchBeanDefinitionException;<br>    <span class="hljs-comment">// 11. 根据名称判断 Bean 是否能被指定的可解析类型解析</span><br>	<span class="hljs-type">boolean</span> <span class="hljs-title function_">isTypeMatch</span><span class="hljs-params">(String name, ResolvableType typeToMatch)</span> <span class="hljs-keyword">throws</span> NoSuchBeanDefinitionException;<br>    <span class="hljs-comment">// 12. 根据名称判断 Bean 是否被指定的字节码对应的类进行解析</span><br>	<span class="hljs-type">boolean</span> <span class="hljs-title function_">isTypeMatch</span><span class="hljs-params">(String name, Class&lt;?&gt; typeToMatch)</span> <span class="hljs-keyword">throws</span> NoSuchBeanDefinitionException;<br>    <span class="hljs-comment">// 13. 根据名称获取 Bean 的类型对应的字节码</span><br>	<span class="hljs-meta">@Nullable</span><br>	Class&lt;?&gt; getType(String name) <span class="hljs-keyword">throws</span> NoSuchBeanDefinitionException;<br>    <span class="hljs-comment">// 14. 根据名称获取 Bean 的类型对应的字节码，并设置是否允许Bean初始化</span><br>	<span class="hljs-meta">@Nullable</span><br>	Class&lt;?&gt; getType(String name, <span class="hljs-type">boolean</span> allowFactoryBeanInit) <span class="hljs-keyword">throws</span> NoSuchBeanDefinitionException;<br>    <span class="hljs-comment">// 15. 获取 Bean的别名</span><br>	String[] getAliases(String name);<br>&#125;<br><br></code></pre></td></tr></table></figure>
<p>根据对 BeanFactory 接口的方法的作用进行概括，可发现其中所有都是关于 Bean 的操作，要么通过 name、类型的字节码去获取 Bean ，要么就是根据名称或者 ResolvableType 来判断 Bean 是 singleton 单例的 还是 prototype 原型的，但是这里面没有关于 Bean 注入的内容，原因是 Spring 底层提供了 Bean 注册中心，而 BeanFactory接口主要只是声明获取 Bean 信息的相关方法。</p>
<p>接下来我们观察 BeanFactory 接口的实现类有哪些：<br>![在这里插入图片描述](<a target="_blank" rel="noopener" href="https://img-blog.csdnimg.cn/552ec3214f2f4a679692615160d306a7.png#">https://img-blog.csdnimg.cn/552ec3214f2f4a679692615160d306a7.png#</a> &#x3D;70%x)</p>
<p>在 Spring 5.3.21 版本中，BeanFactory 的工厂实现类多达50个，这里我们不一一的去查看，通常其实现的非抽象类都会继承于指定的抽象类，然后又实现该抽象类的接口，这是一种结构型的设计模式。（具体是什么我忘记了）。</p>
<p>所以我们可以先看其抽象实现类，目前 BeanFactory 的抽象实现类就图中的七个</p>
<p>首先关注 AbstractApplicationContext 这个抽象类，因为当我们在获取 Spring中的 Bean时，可以通过工厂也可以通过应用上下文</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-keyword">public</span> <span class="hljs-keyword">abstract</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">AbstractApplicationContext</span> <span class="hljs-keyword">extends</span> <span class="hljs-title class_">DefaultResourceLoader</span><br>		<span class="hljs-keyword">implements</span> <span class="hljs-title class_">ConfigurableApplicationContext</span> &#123;<br>&#125;<br></code></pre></td></tr></table></figure>
<p>比如在传统的 Spring 开发中获取Bean，通过 Spring 的应用上下文获取。</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs java"><br><span class="hljs-type">ApplicationContext</span> <span class="hljs-variable">context</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">ClassPathXmlApplicationContext</span>(<span class="hljs-string">&quot;applicationContext.xml&quot;</span>);<br><span class="hljs-type">User</span> <span class="hljs-variable">user</span> <span class="hljs-operator">=</span> (User) context.getBean(User.class);<br><br></code></pre></td></tr></table></figure>
<p>这里是通过 Spring 配置文件来创建 ClassPathXmlApplicationContext 对象</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">ClassPathXmlApplicationContext</span> <span class="hljs-keyword">extends</span> <span class="hljs-title class_">AbstractXmlApplicationContext</span> &#123;<br>&#125;<br></code></pre></td></tr></table></figure>

<p>单从其父类来看，ClassPathXmlApplicationContext 似乎并不是抽象类 AbstractApplicationContext 的子类，但是从它的类名里可以看出，都带着 ApplicationContext后缀，必然是实现了同一个接口，这里我使用 IDEA 工具对类的关系进行可视化可以得出下图，ClassPathXMLApplicationContext 是 AbstractApplicationContext 的间接子类<br>![在这里插入图片描述](<a target="_blank" rel="noopener" href="https://img-blog.csdnimg.cn/485849afbff349efb02fdbe084262a92.png#">https://img-blog.csdnimg.cn/485849afbff349efb02fdbe084262a92.png#</a> &#x3D;60%x)</p>
<p>在 Spring 底层，BeanFactory 接口的子类除了 ClassPathXmlApplicationContext，还有 XmlWebApplicationContext、StaticWebApplicationContext、StaticApplicationContext，如下图<br>![在这里插入图片描述](<a target="_blank" rel="noopener" href="https://img-blog.csdnimg.cn/7e6f6f09bce646d0ab7fb95fc693bdb6.png#">https://img-blog.csdnimg.cn/7e6f6f09bce646d0ab7fb95fc693bdb6.png#</a> &#x3D;60%x)</p>
<p>而这些类直接不一定是直接继承的关系，也有可能是间接继承，即中间还有其他的抽象类，它们都实现了 ApplicationContext 这个接口</p>
<p>在 Spring 底层，org.springframework.beans.factory.support.DefaultListableBeanFactory  实现了所有工厂的逻辑</p>
<h1 id="三、总结"><a href="#三、总结" class="headerlink" title="三、总结"></a>三、总结</h1><hr>
<p>Spring 中 BeanFactory 接口声明了关于获取 Bean信息的方法，其他所有的工厂都是 BeanFactory 的子类，虽然在 BeanFactory 里没有显式地声明具体有哪些工厂，但是那些工厂都需要实现这个接口，这也是一种抽象工厂模式的设计方法，BeanFactory相当于抽象工厂，而其继承子类就相当于产品，不同的工厂类就相当于不同的产品。</p>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/categories/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/" class="category-chain-item">设计模式</a>
  
  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/tags/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/">#设计模式</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>设计模式 笔记7 _ 抽象工厂模式 在源码中的应用 Spring篇</div>
      <div>http://example.com/2022/07/25/设计模式 笔记7 _ 抽象工厂模式 在源码中的应用 Spring篇/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>John Doe</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2022年7月25日</div>
        </div>
      
      
      <div class="license-meta-item">
        <div>许可协议</div>
        <div>
          
            
            
              <a target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
              <span class="hint--top hint--rounded" aria-label="BY - 署名">
                <i class="iconfont icon-by"></i>
              </span>
              </a>
            
          
        </div>
      </div>
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2022/07/26/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F%20%E7%AC%94%E8%AE%B08%20_%20%E5%BB%BA%E9%80%A0%E8%80%85%E6%A8%A1%E5%BC%8F%20%E5%9C%A8%E6%BA%90%E7%A0%81%E4%B8%AD%E7%9A%84%E5%BA%94%E7%94%A8%20StringBuilder%20%E7%9A%84%20append%20_%20MyBatis%20%E7%9A%84%20SqlSessionFactoryBuilder%20%E5%92%8C%20ConfigBuilder/" title="设计模式 笔记8 _ 建造者模式 在源码中的应用 StringBuilder 的 append _ MyBatis 的 SqlSessionFactoryBuilder 和 ConfigBuilder">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">设计模式 笔记8 _ 建造者模式 在源码中的应用 StringBuilder 的 append _ MyBatis 的 SqlSessionFactoryBuilder 和 ConfigBuilder</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2022/07/24/Web%E5%BC%80%E5%8F%91%20%E8%BA%AB%E4%BB%BD%E9%AA%8C%E8%AF%812%20_%20SpringBoot%20%E6%95%B4%E5%90%88%20JWT%20_%20%E5%89%8D%E5%90%8E%E7%AB%AF%E5%88%86%E7%A6%BB%E7%AD%96%E7%95%A5%20_%20%E8%B7%A8%E5%9F%9F%E9%97%AE%E9%A2%98%E7%9A%84%E5%87%BA%E7%8E%B0%E4%B8%8E%E8%A7%A3%E5%86%B3/" title="Web开发 身份验证2 _ SpringBoot 整合 JWT _ 前后端分离策略 _ 跨域问题的出现与解决">
                        <span class="hidden-mobile">Web开发 身份验证2 _ SpringBoot 整合 JWT _ 前后端分离策略 _ 跨域问题的出现与解决</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
    </div>
  
  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      headingSelector : CONFIG.toc.headingSelector || 'h1,h2,h3,h4,h5,h6',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      collapseDepth   : CONFIG.toc.collapseDepth || 0,
      scrollSmooth    : true,
      headingsOffset  : -boardTop
    });
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.10/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/js/local-search.js" ></script>





<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
